#import "sprite_game_dlg_tutorial.h"

#import "scene_game.h"
#import "layer_game_object.h"

#define SPRITE_GAME_TUTORIAL_FONT_NAME @"ArialMT"

#if (HARD_WARE == HARD_WARE_IPHONE)
	#define SPRITE_GAME_TUTORIAL_FONT_SIZE 16
#elif (HARD_WARE == HARD_WARE_IPAD)
	#define SPRITE_GAME_TUTORIAL_FONT_SIZE 32
#endif

@implementation SpriteGameDlgTutorial

- (id)initSpriteDlgGameTutorial
{
	CCLabelTTF *_Label;
	std::vector<CCLabelTTF *> _Table;

	int i;
	float _TotalH;
	float _StartY;

	if ((self = [super init]))
	{
		[g_SceneGame.layerObject ClearArrow];

		type_ = Type;
		switch (Type)
		{
		case SPRITE_GAME_TUTORIAL_TYPE_MAIN:
			/*time bar
			*/
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"时间条" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Time Bar" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(320, 860);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(384, 860);
#endif

			_Label = [CCLabelTTF labelWithString:@"↑" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(320, 900);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(384, 900);
#endif

			/*bridge
			*/
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"能量桥" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Bridge" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(80, 320);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(80, 320);
#endif

			_Label = [CCLabelTTF labelWithString:@"↓" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(80, 280);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(80, 280);
#endif

			/*bow
			*/
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"←弓" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"←Bow" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(500, 224);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(500, 224);
#endif

			/*item holder
			*/
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"←物品栏→" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"←Item holder→" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(320, 120);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(384, 120);
#endif

			/*menu button
			*/
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"菜单→" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Menu Button→" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
#if (HARD_WARE == HARD_WARE_IPHONE)
			_Label.positionInPixels = ccp(400, 30);
#elif (HARD_WARE == HARD_WARE_IPAD)
			_Label.positionInPixels = ccp(400, 30);
#endif

			centerRect_.center = g_ScrrenCenter;
			centerRect_.size = g_ScrrenSize;
			break;
		case SPRITE_GAME_TUTORIAL_TYPE_HEART_APPEAR:
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"射击爱心以收集爱心能量!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"拖拽你的弓弦以瞄准射击," fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"拉弓蓄力以释放强力攻击!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Shoot the flying love heart" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"to collect energy for your bridge!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"Drag the arrow to shoot!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"Hold to charge a powerful attack!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			break;
		case SPRITE_GAME_TUTORIAL_TYPE_HEART_GET:
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"能量强增长了!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"收集100分的爱心以通关." fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Bridge energy grows!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"Collect 100 Love point to" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"complete the mission!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			break;
		case SPRITE_GAME_TUTORIAL_TYPE_ENEMY:
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"怪物会出现阻扰你的爱心收集," fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"有些怪物会为你掉落爱心." fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"干掉怪物以收集更多的爱心." fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Monsters  will disturb your Love collecting," fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"and someone will drop love heart for you!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
				_Label = [CCLabelTTF labelWithString:@"Finish them to collect more love heart!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
				[self addChild:_Label];
				_Label.anchorPoint = ccp(0.5f, 1.0f);
				_Table.push_back(_Label);
			}
			break;
		case SPRITE_GAME_TUTORIAL_TYPE_OVER:
			if (g_FlagChinese)
			{
				_Label = [CCLabelTTF labelWithString:@"祝你好运!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			else
			{
				_Label = [CCLabelTTF labelWithString:@"Good Luck!" fontName:SPRITE_GAME_TUTORIAL_FONT_NAME fontSize:SPRITE_GAME_TUTORIAL_FONT_SIZE];
			}
			[self addChild:_Label];
			_Label.anchorPoint = ccp(0.5f, 1.0f);
			_Table.push_back(_Label);
			break;
		default:;
		}

		if (_Table.size())
		{
			_TotalH = _Table.size() * _Table[0].contentSizeInPixels.height + (_Table.size() - 1) * SPRITE_GAME_TUTORIAL_LINE_OFFSET;
			_StartY = _TotalH / 2.0f;
			for (i = 0; i < _Table.size(); i++)
			{
				_Table[i].positionInPixels = ccp(g_ScrrenCenter.x, _StartY + g_ScrrenCenter.y);
				_StartY -= _Table[i].contentSizeInPixels.height + SPRITE_GAME_TUTORIAL_LINE_OFFSET;
			}

			centerRect_.center = g_ScrrenCenter;
			centerRect_.size = CGSizeMake(g_ScrrenSize.width, _TotalH + 200);
		}
	}
	return self;
}

- (void)actionCloseOver
{
	switch (type_)
	{
	case SPRITE_GAME_TUTORIAL_TYPE_MAIN:[g_SceneGame.layerObject ActionToturialMainOver]; break;
	case SPRITE_GAME_TUTORIAL_TYPE_HEART_APPEAR:[g_SceneGame.layerObject ActionToturialHeartAppearOver]; break;
	case SPRITE_GAME_TUTORIAL_TYPE_HEART_GET:[g_SceneGame.layerObject ActionToturialHeartGetOver]; break;
	case SPRITE_GAME_TUTORIAL_TYPE_ENEMY:[g_SceneGame.layerObject ActionToturialEnemyOver]; break;
	case SPRITE_GAME_TUTORIAL_TYPE_OVER:[g_SceneGame.layerObject ActionToturialOverOver]; break;
	default:;
	}
}

@end